<?php

namespace Access\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class AccessController extends AbstractActionController
{
    protected $accessTable;
    protected $withdraw;
    protected $deposit;
    protected $access;

    public function getAccessTable()
    {
        if (!$this->accessTable) {
            $sm = $this->getServiceLocator();
            $this->accessTable = $sm->get('Access\Model\AccessTable');
        }
        return $this->accessTable;
    }

    public function indexAction()
    {
        $this->access = $this->getAccessTable()->fetchAll();
        $view = new ViewModel(array(
            'access' => $this->access
        ));
        return $view;
    }

    public function withdrawAction()
    {
        $this->withdraw = $this->getAccessTable()->getWithdraw();
        $view = new ViewModel(array(
            'withdraw' => $this->withdraw
        ));
        return $view;
    }

    public function depositAction()
    {
        $this->deposit = $this->getAccessTable()->getDeposit();
        $view = new ViewModel(array(
            'deposit' => $this->deposit
        ));
        return $view;
    }
}